package cn.hiapi.admin.query;

import cn.hiapi.basic.entity.BasicEntity;
import cn.hiapi.basic.jpa.pageable.QueryWrapper;
import cn.hiapi.basic.jpa.query.BasicQuery;
import cn.hiapi.shopkeeper.enums.ActivityType;
import cn.hiapi.shopkeeper.enums.OrderStatus;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;

import javax.persistence.EnumType;
import javax.persistence.Enumerated;

/**
 * @author AdinZ
 * @date 2022/12/18 18:24
 */
@Setter
@Getter
public class ActivityOrderQuery extends BasicQuery {
    @ApiModelProperty("店铺名字")
    private String shopName;
    @ApiModelProperty("店铺id")
    private Long shopId;
    @ApiModelProperty("商品标题")
    private String title;
    @ApiModelProperty("买家id")
    private Long buyerId;
    @ApiModelProperty("活动id")
    private Long aid;
    @ApiModelProperty("买家id")
    private Long[] time;
    @ApiModelProperty("买家手机号")
    private String mobile;

    @ApiModelProperty("活动类型")
    private ActivityType activityType;
    @ApiModelProperty("订单状态")
    private OrderStatus status ;

    @ApiModelProperty("付款信息")
    private String payType;
    @Override
    public QueryWrapper getQueryWrapper() {
        QueryWrapper wrapper = super.getBasicQueryWrapper();
        wrapper.eq("shopId", shopId)
                .eq("buyerId", buyerId)
                .eq("aid", aid)
                .eq("payType", payType)
                .eq("activityType", activityType)
                .between("created", time)
                .eq("status", status);
        if (StringUtils.isNotEmpty(title)) {
            wrapper.like("title", "%" + title + "%");
        }
        return wrapper;
    }
}
